#include "lepf.h"
#include "controls/dialog/ldialog.h"


#include <QPushButton>

LEPF::LApp::LApp(int argc, char* argv[])
    : m_app(argc, argv)
{
    for (int i = 0; i < argc; ++i) {
        std::cout << argv[i] << std::endl;
    }
}

bool LEPF::LApp::CreateApplicationByXML(const std::string& xmlPath)
{
    pugi::xml_document doc;
    pugi::xml_parse_result res = doc.load_file(xmlPath.c_str());
    if (res.status != pugi::xml_parse_status::status_ok) {
        std::cout << "XML Parse Error Message:" << res.description() << std::endl;
        return false;
    }
    LDialog* pDialog = nullptr;
    pugi::xml_node rootNode = doc.first_child();
    if (rootNode.name() == std::string("dialog")) {
        pDialog = new LDialog;
        pDialog->show();
    }
    pugi::xml_node childNodes = rootNode.first_child();
    while (!childNodes.empty()) {
        std::cout << "name=" << childNodes.name() << std::endl;
        // 打印所有的属性
        for (auto it : childNodes.attributes()) {
            std::cout << it.name() << ":" << it.value() << std::endl;
        }
        childNodes = childNodes.next_sibling();
    }

    //std::cout << "文件加载成功\n";
    return m_app.exec();
}
